const dbConfig = require('./dbconfig');
const Sequelize = require('sequelize');

const sequelize = new Sequelize(dbConfig.MYSQL.DATABASE, dbConfig.MYSQL.USERNAME, dbConfig.MYSQL.PASSWORD, {
    host: dbConfig.MYSQL.HOST,
    dialect: dbConfig.MYSQL.DIALECT,
    pool: dbConfig.MYSQL.POOL
});

//连接测试
sequelize.authenticate()
    .then(() => {
        console.log('Connection has been established successfully.');
    })
    .catch(err => {
        console.error('Unable to connect to the database:', err);
    })

module.exports = sequelize;